<template>
    <div class="goods-list">
        <div class="goods-item">
            <img src="//img10.360buyimg.com/mobilecms/s372x372_jfs/t1/9689/1/9137/333316/5c11c30aEc77cca39/73afeba8886a8a00.jpg!q70.dpg" alt="">
            <h1 class="title">青苹果  高硼硅玻璃杯茶水分离杯双层耐热泡茶杯子带过滤玻璃水杯GPB02</h1>
            <div class="info">
                <div class="price">
                    <span class="new">￥999</span>
                    <span class="old">￥2399</span>
                </div>
                <div class="sell">
                    <span>热卖中</span>
                    <span>剩60件</span>
                </div>
            </div>
        </div>
        <div class="goods-item" @click="goDetail(22)">
            <img src="//img12.360buyimg.com/mobilecms/s372x372_jfs/t1/21940/25/1816/279968/5c1741f9E09677b33/6bb7cca2137dc8c1.jpg!q70.dpg" alt="">
            <h1 class="title">伊利 纯牛奶250ml*24盒</h1>
            <div class="info">
                <div class="price">
                    <span class="new">￥999</span>
                    <span class="old">￥2399</span>
                </div>
                <div class="sell">
                    <span>热卖中</span>
                    <span>剩60件</span>
                </div>
            </div>
        </div>
        <div class="goods-item" @click="goback">
            <img src="//img12.360buyimg.com/mobilecms/s372x372_jfs/t1/10948/19/1851/133787/5bdf0862E89470617/0be255fec4b97d5e.jpg!q70.dpg" alt="">
            <h1 class="title">青苹果  高硼硅玻璃杯茶水分离杯双层耐热泡茶杯子带过滤玻璃水杯GPB02</h1>
            <div class="info">
                <div class="price">
                    <span class="new">￥999</span>
                    <span class="old">￥2399</span>
                </div>
                <div class="sell">
                    <span>热卖中</span>
                    <span>剩60件</span>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            
        }
    },
    methods: {
        goDetail(id){
            // this.$route 和 this.$router
            // this.$route 其中前者是路由参数对象， params 和query都属于它
            // this.$router 是一个路由导航对象， 用他可以方便的使用js代码，实现路由的前进、后退，跳转到新的URL地址
            console.log(this);
            // 1.最简单
            // this.$router.push('/home/goodsinfo/' + id);
            // 2.传递对象
            // this.$router.push({ path: '/home/goodsinfo/' + id });
            // 3.传递命名的路由
            // name 属性就是定义路由的名称
            this.$router.push({name: 'goodsinfo', params: { id }});
        },
        goback(){
            // 测试路由跳转中的几个属性
            this.$router.go(-1);
        }
    }
}
</script>

<style lang="scss" scoped>
.goods-list{
    background-color: #f0f2f5;
    display: flex;
    flex-wrap: wrap;
    padding: 0 7px;
    justify-content: space-between;
}
.goods-item{
    background-color: #fff;
    width: 49%;
    border: 1px solid #eee;
    margin: 2px 0;
    padding: 2px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 293px;
    img{
        width: 100%;
    }
    .title{
        font-size: 14px;
    }
    .info{
        background-color: #eee;
        p{
            margin: 0;
            padding: 5px;
        }
        .price{
            .new{
                color: red;
                font-weight: bold;
                font-size: 16px;
            }
            .old{
                text-decoration: line-through;
                font-size: 12px;
                margin-left: 10px;
            }
        }
        .sell{
            display: flex;
            justify-content: space-between;
            font-size: 12px;
        }
    }
}
</style>
